package cn.accp.petShop.baseEntity;

//final 修饰类，表明该类不得继承
public abstract class PetBase {
	private int id;
	protected String name;
	// 品种
	private String type;
	// 可爱度
	protected int lovely;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getLovely() {
		return lovely;
	}

	public void setLovely(int lovely) {
		this.lovely = lovely;
	}

	public PetBase() {
		System.out.println("Pet类的默认构造方法运行了！");
	}

	// 带参数的构造方法
	public PetBase(int id, String name, String type, int lovely) {
		super();
		this.id = id;
		this.name = name;
		this.type = type;
		this.lovely = lovely;
		System.out.println("Pet类的带参构造方法运行了！");
	}

	public void showMe() {
		System.out.println(this.id + "," + this.name + "," + this.type + ","
				+ this.lovely);
	}

	// final 修饰的话只能不继承，不得被重写
	// 抽象方法,吃
	public abstract void eat();

	// 抽象方法,跑
	public abstract void run();

	@Override
	public String toString() {
		return this.id + "," + this.name + "," + this.type + "," + this.lovely;
	}

	@Override
	public boolean equals(Object obj) {
		// 默认的对比两个对象的引用地址，重写之后是对比两个对象类名和类内的属性
		if (obj instanceof PetBase) {
			PetBase pet = (PetBase) obj;
			return pet.id == this.id && pet.name.equals(this.name)
					&& pet.lovely == this.lovely && pet.type.equals(this.type);
		} else {
			return false;
		}
	}
}
